package c.h.a.x.s;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.TextView;
import c.d.a.a.c.j;
import c.d.a.a.c.k;
import c.h.a.m0.h;
import c.h.b.b.e.a;
import c.h.b.b.e.d;
import c.h.b.b.e.e;
import c.h.b.b.e.f;
import c.h.b.b.e.g;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.data.PieEntry;
import com.liuzh.deviceinfo.DeviceInfoApp;
import com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeActivity;
import com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeActivity.c;
import com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/* compiled from: lambda */
public final /* synthetic */ class b implements OnClickListener {
    public final /* synthetic */ c a;
    public final /* synthetic */ i b;

    public /* synthetic */ b(c cVar, i iVar) {
        this.a = cVar;
        this.b = iVar;
    }

    public final void onClick(View view) {
        int i;
        int i2;
        int i3;
        int i4;
        CharSequence string;
        CharSequence string2;
        CharSequence charSequence;
        String string3;
        c cVar = this.a;
        i iVar = this.b;
        AppsAnalyzeActivity appsAnalyzeActivity = AppsAnalyzeActivity.this;
        appsAnalyzeActivity.y.removeAllViews();
        if (appsAnalyzeActivity.z == null) {
            appsAnalyzeActivity.z = new AppsAnalyzeResultDetailView(appsAnalyzeActivity.u);
        }
        FrameLayout frameLayout = appsAnalyzeActivity.y;
        AppsAnalyzeResultDetailView appsAnalyzeResultDetailView = appsAnalyzeActivity.z;
        Objects.requireNonNull(iVar);
        ArrayList arrayList = new ArrayList();
        c.h.b.b.e.b bVar = iVar.b;
        boolean z = bVar instanceof a;
        Integer valueOf = Integer.valueOf(-1);
        Integer valueOf2 = Integer.valueOf(2);
        Integer valueOf3 = Integer.valueOf(1);
        Integer valueOf4 = Integer.valueOf(0);
        List list;
        int i5;
        if (z) {
            Drawable drawable;
            a aVar = (a) bVar;
            List list2 = (List) aVar.a.get(valueOf3);
            if (list2 == null) {
                i = 0;
            } else {
                i = list2.size();
            }
            if (i != 0) {
                Drawable drawable2 = iVar.a.getDrawable(2131230993);
                if (drawable2 != null) {
                    int n = c.f.a.a.a.a.n(iVar.a, 16843829);
                    boolean z2 = h.a;
                    drawable2 = c.b.a.a.a.x(drawable2, n);
                }
                AppsAnalyzeResultDetailView.a aVar2 = r14;
                AppsAnalyzeResultDetailView.a aVar3 = new AppsAnalyzeResultDetailView.a("64bit", i, iVar.a(0), list2, drawable2);
                arrayList.add(aVar2);
                i += 0;
            } else {
                i = 0;
            }
            list = (List) aVar.a.get(Integer.valueOf(3));
            if (list == null) {
                i2 = 0;
            } else {
                i2 = list.size();
            }
            list2 = (List) aVar.a.get(valueOf2);
            if (list2 == null) {
                i5 = 0;
            } else {
                i5 = list2.size();
            }
            i2 += i5;
            if (i2 != 0) {
                drawable = iVar.a.getDrawable(2131230992);
                if (drawable != null) {
                    int n2 = c.f.a.a.a.a.n(iVar.a, 16843829);
                    boolean z3 = h.a;
                    drawable = c.b.a.a.a.x(drawable, n2);
                }
                arrayList.add(new AppsAnalyzeResultDetailView.a("32bit", i2, iVar.a(1), list2, drawable));
                i += i2;
            }
            list2 = (List) aVar.a.get(valueOf);
            if (list2 == null) {
                i3 = 0;
            } else {
                i3 = list2.size();
            }
            if (i3 != 0) {
                drawable = iVar.a.getDrawable(2131230995);
                if (drawable != null) {
                    i2 = c.f.a.a.a.a.n(iVar.a, 16843829);
                    boolean z4 = h.a;
                    drawable = c.b.a.a.a.x(drawable, i2);
                }
                arrayList.add(new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690514), i3, iVar.a(2), list2, drawable));
                i += i3;
            }
            list2 = (List) aVar.a.get(valueOf4);
            if (list2 == null) {
                i4 = 0;
            } else {
                i4 = list2.size();
            }
            if (i4 != 0) {
                Drawable drawable3 = iVar.a.getDrawable(2131230994);
                if (drawable3 != null) {
                    i5 = c.f.a.a.a.a.n(iVar.a, 16843829);
                    boolean z5 = h.a;
                    drawable3 = c.b.a.a.a.x(drawable3, i5);
                }
                arrayList.add(new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690131), i4, iVar.a(3), list2, drawable3));
                i += i4;
            }
            string = iVar.a.getString(2131690121);
            string2 = iVar.a.getString(2131690122);
            charSequence = "app_ana_abi_cli";
        } else {
            String str = "API ";
            StringBuilder g;
            if (bVar instanceof g) {
                Iterator it = ((g) bVar).a.iterator();
                i = 0;
                i3 = 0;
                while (it.hasNext()) {
                    g.a aVar4 = (g.a) it.next();
                    g = c.b.a.a.a.g(str);
                    g.append(aVar4.a);
                    Iterator it2 = it;
                    AppsAnalyzeResultDetailView.a aVar5 = r10;
                    AppsAnalyzeResultDetailView.a aVar6 = new AppsAnalyzeResultDetailView.a(g.toString(), aVar4.b.size(), iVar.a(i3), aVar4.b, iVar.a.getDrawable(h.b(aVar4.a)));
                    arrayList.add(aVar5);
                    i3++;
                    i += aVar4.b.size();
                    it = it2;
                }
                string = iVar.a.getString(2131690439);
                string2 = iVar.a.getString(2131690440);
                charSequence = "app_ana_tgt_cli";
            } else {
                if (bVar instanceof e) {
                    i4 = 0;
                    i = 0;
                    for (e.a aVar7 : ((e) bVar).a) {
                        g = c.b.a.a.a.g(str);
                        g.append(aVar7.a);
                        arrayList.add(new AppsAnalyzeResultDetailView.a(g.toString(), aVar7.b.size(), iVar.a(i), aVar7.b, iVar.a.getDrawable(h.b(aVar7.a))));
                        i++;
                        i4 += aVar7.b.size();
                    }
                    string3 = iVar.a.getString(2131690071);
                    string2 = iVar.a.getString(2131690072);
                    charSequence = "app_ana_min_cli";
                    i = i4;
                } else {
                    String str2;
                    Object obj;
                    List list3;
                    if (bVar instanceof d) {
                        d dVar = (d) bVar;
                        Set<String> keySet = dVar.a.keySet();
                        Drawable drawable4 = iVar.a.getDrawable(17629184);
                        i3 = 0;
                        i5 = 0;
                        for (String str3 : keySet) {
                            List list4 = (List) dVar.a.get(str3);
                            if (list4 != null) {
                                Drawable drawable5;
                                String string4 = str3 == null ? iVar.a.getString(2131690514) : str3;
                                if ("system".equalsIgnoreCase(string4)) {
                                    str3 = iVar.a.getString(2131690430);
                                    drawable5 = drawable4;
                                } else {
                                    Drawable loadIcon;
                                    try {
                                        PackageManager b = DeviceInfoApp.c.b();
                                        ApplicationInfo applicationInfo = b.getPackageInfo(str3, 0).applicationInfo;
                                        string4 = applicationInfo.loadLabel(b).toString();
                                        loadIcon = applicationInfo.loadIcon(b);
                                    } catch (Exception unused) {
                                        loadIcon = drawable4;
                                    }
                                    if (!TextUtils.isEmpty(string4.trim())) {
                                        str3 = string4;
                                    }
                                    drawable5 = loadIcon;
                                }
                                i3 = c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(str3, list4.size(), iVar.a(i5), list4, drawable5), list4, i3);
                                i5++;
                            }
                        }
                        string3 = iVar.a.getString(2131689566);
                        string2 = iVar.a.getString(2131690014);
                        str2 = "app_ana_istl_cli";
                    } else if (bVar instanceof f) {
                        f fVar = (f) bVar;
                        i = 0;
                        i3 = 0;
                        for (String str4 : fVar.a.keySet()) {
                            list3 = (List) fVar.a.get(str4);
                            if (list3 != null) {
                                i3 = c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(str4, list3.size(), iVar.a(i), list3, iVar.a.getDrawable(2131231080)), list3, i3);
                                i++;
                            }
                        }
                        string3 = iVar.a.getString(2131690358);
                        string2 = iVar.a.getString(2131690359);
                        str2 = "app_ana_sig_cli";
                    } else if (bVar instanceof c.h.b.b.e.c) {
                        c.h.b.b.e.c cVar2 = (c.h.b.b.e.c) bVar;
                        Drawable drawable6 = iVar.a.getDrawable(2131231052);
                        List list5 = (List) cVar2.a.get(valueOf4);
                        i = list5 != null ? c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690008), list5.size(), iVar.a(0), list5, drawable6), list5, 0) : 0;
                        list = (List) cVar2.a.get(valueOf3);
                        if (list != null) {
                            i = c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690011), list.size(), iVar.a(1), list, drawable6), list, i);
                        }
                        list3 = (List) cVar2.a.get(valueOf2);
                        if (list3 != null) {
                            i = c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690012), list3.size(), iVar.a(2), list3, drawable6), list3, i);
                        }
                        List list6 = (List) cVar2.a.get(valueOf);
                        if (list6 != null) {
                            i = c.b.a.a.a.m(arrayList, new AppsAnalyzeResultDetailView.a(iVar.a.getString(2131690514), list6.size(), iVar.a(3), list6, drawable6), list6, i);
                        }
                        string3 = iVar.a.getString(2131690007);
                        string2 = iVar.a.getString(2131690009);
                        str2 = "app_ana_istlc_cli";
                        obj = str2;
                    } else {
                        string2 = null;
                        string = null;
                        i = 0;
                        charSequence = null;
                    }
                    i = i3;
                    obj = str2;
                }
                string = string3;
            }
        }
        if (!arrayList.isEmpty() && !TextUtils.isEmpty(string) && !TextUtils.isEmpty(string2)) {
            c.d.a.a.c.d dVar2;
            if (!TextUtils.isEmpty(charSequence)) {
                c.h.a.v.a.b.c(charSequence, null);
            }
            appsAnalyzeResultDetailView.scrollTo(0, 0);
            appsAnalyzeResultDetailView.b.setText(string);
            i3 = h.r() ? 140 : 240;
            if (string2.length() > i3) {
                string3 = string2.substring(0, i3);
                String string5 = appsAnalyzeResultDetailView.getResources().getString(2131690284);
                CharSequence spannableString = new SpannableString(c.b.a.a.a.E(string3, "...\n", string5));
                int length = spannableString.length() - string5.length();
                i3 = string5.length() + length;
                spannableString.setSpan(new ForegroundColorSpan(c.f.a.a.a.a.n(appsAnalyzeResultDetailView.getContext(), 16842907)), length, i3, 18);
                spannableString.setSpan(new UnderlineSpan(), length, i3, 18);
                appsAnalyzeResultDetailView.c.setOnClickListener(new g(appsAnalyzeResultDetailView, string, string2));
                dVar2 = null;
                string2 = spannableString;
            } else {
                appsAnalyzeResultDetailView.c.setOnClickListener(null);
                dVar2 = null;
            }
            appsAnalyzeResultDetailView.c.setText(string2);
            PieChart pieChart = appsAnalyzeResultDetailView.a;
            pieChart.b = dVar2;
            pieChart.z = false;
            pieChart.A = dVar2;
            pieChart.n.c = dVar2;
            pieChart.invalidate();
            ArrayList arrayList2 = new ArrayList();
            ArrayList arrayList3 = new ArrayList();
            Iterator it3 = arrayList.iterator();
            while (it3.hasNext()) {
                AppsAnalyzeResultDetailView.a aVar8 = (AppsAnalyzeResultDetailView.a) it3.next();
                i2 = aVar8.a;
                if (i2 != 0) {
                    arrayList2.add(new PieEntry((float) i2, aVar8.b));
                    arrayList3.add(Integer.valueOf(aVar8.c));
                }
            }
            k kVar = new k(arrayList2, string);
            kVar.a = arrayList3;
            kVar.f = new c.d.a.a.d.d(appsAnalyzeResultDetailView.a);
            kVar.x = -7829368;
            k.a aVar9 = k.a.OUTSIDE_SLICE;
            kVar.w = aVar9;
            kVar.v = aVar9;
            float f = 1.0f;
            kVar.E0(1.0f);
            kVar.j = false;
            j jVar = new j(kVar);
            c.d.a.a.b.c cVar3 = new c.d.a.a.b.c();
            cVar3.f = "";
            PieChart pieChart2 = appsAnalyzeResultDetailView.a;
            pieChart2.setRenderer(new m(pieChart2));
            appsAnalyzeResultDetailView.a.setUsePercentValues(true);
            appsAnalyzeResultDetailView.a.setDescription(cVar3);
            appsAnalyzeResultDetailView.a.setData(jVar);
            appsAnalyzeResultDetailView.a.setDrawCenterText(true);
            pieChart = appsAnalyzeResultDetailView.a;
            pieChart.setExtraLeftOffset(26.0f);
            pieChart.setExtraTopOffset(5.0f);
            pieChart.setExtraRightOffset(26.0f);
            pieChart.setExtraBottomOffset(5.0f);
            appsAnalyzeResultDetailView.a.setEntryLabelColor(c.f.a.a.a.a.n(appsAnalyzeResultDetailView.getContext(), 16842806));
            appsAnalyzeResultDetailView.a.setEntryLabelTextSize(10.0f);
            appsAnalyzeResultDetailView.a.getLegend().a = false;
            appsAnalyzeResultDetailView.a.setHoleColor(0);
            appsAnalyzeResultDetailView.a.setCenterText(string);
            appsAnalyzeResultDetailView.a.setCenterTextColor(c.f.a.a.a.a.n(appsAnalyzeResultDetailView.getContext(), 2130968786));
            appsAnalyzeResultDetailView.a.setCenterTextSize(12.0f);
            appsAnalyzeResultDetailView.a.setOnChartValueSelectedListener(new k(appsAnalyzeResultDetailView, i, string));
            LayoutInflater from = LayoutInflater.from(appsAnalyzeResultDetailView.getContext());
            i4 = 0;
            while (i4 < arrayList.size()) {
                com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView.b bVar2;
                AppsAnalyzeResultDetailView.a aVar10 = (AppsAnalyzeResultDetailView.a) arrayList.get(i4);
                View childAt = appsAnalyzeResultDetailView.d.getChildAt(i4);
                if (childAt == null) {
                    childAt = from.inflate(2131492906, appsAnalyzeResultDetailView.d, false);
                    bVar2 = new com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView.b(childAt);
                    appsAnalyzeResultDetailView.d.addView(childAt);
                } else if (childAt.getTag() instanceof com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView.b) {
                    bVar2 = (com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView.b) childAt.getTag();
                } else {
                    bVar2 = new com.liuzh.deviceinfo.appinfo.appanalyze.AppsAnalyzeResultDetailView.b(childAt);
                }
                string3 = appsAnalyzeResultDetailView.a(((((float) aVar10.a) * f) / ((float) i)) * f);
                bVar2.a.setText(aVar10.b);
                TextView textView = bVar2.b;
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append(bVar2.a.getContext().getString(2131690027, new Object[]{Integer.valueOf(aVar10.a)}));
                stringBuilder.append(" (");
                stringBuilder.append(string3);
                stringBuilder.append(")");
                textView.setText(stringBuilder.toString());
                bVar2.c.setMax(i);
                bVar2.c.setProgress(aVar10.a);
                bVar2.f.setImageDrawable(aVar10.e);
                bVar2.d.setBackgroundColor(aVar10.c);
                bVar2.e.setOnClickListener(new f(aVar10));
                childAt.setTag(bVar2);
                i4++;
                f = 1.0f;
            }
            if (appsAnalyzeResultDetailView.d.getChildCount() > arrayList.size()) {
                appsAnalyzeResultDetailView.d.removeViews(arrayList.size(), appsAnalyzeResultDetailView.d.getChildCount() - arrayList.size());
            }
            frameLayout.addView(appsAnalyzeResultDetailView, -1, -1);
        }
    }
}
